package com.sunagy.demand.front.controller;

import com.sunagy.demand.front.VO.ResultVO;
import com.sunagy.demand.front.dto.CustomerProgressDto;
import com.sunagy.demand.front.service.CustomerProgressService;
import com.sunagy.demand.front.utils.ResultVOUtil;
import com.sunagy.demand.front.utils.UserContext;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * desc：用户需求进程接口
 * author：三餘無夢生
 * date：2018/4/11
 * time：下午4:10
 */
@Slf4j
@RestController
@RequestMapping("/customerProgress")
@Api(value = "客户端需求进程", description = "需求互动过程中相关接口")
public class CustomerProgressController {

    @Autowired
    private CustomerProgressService customerProgressService;

    @ApiOperation(value = "查询我的需求进程", notes = "根据用户token信息查询用户自己的需求进程，如果没有进程自动创建一个通用进程")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "java.lang.String", name = "Authorization", value = "token", required = false, paramType = "header")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "接口异常")
    })
    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResultVO<List<CustomerProgressDto>> getList() {
        log.info("查询我的需求进程");
        List<CustomerProgressDto> customerProgressDtoList = customerProgressService.getEnableListByUserId(UserContext.getUserID());
        return ResultVOUtil.success(customerProgressDtoList);
    }

}
